package cn.quickcode.monitor;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor
{

	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
	{
		super(configurer);
	}

	/**
	 * @wbp.parser.entryPoint
	 */
	public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer)
	{
		return new ApplicationActionBarAdvisor(configurer);
	}

	/**
	 * @wbp.parser.entryPoint
	 */
	public void preWindowOpen()
	{
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		// 取屏幕大小，启动时最大化 ？启动后虽布满屏幕，但不是最大化状态
		Rectangle screenSize = Display.getDefault().getClientArea();
		configurer.setInitialSize(new Point(screenSize.width*3/4, screenSize.height*3/4));
		configurer.setShowCoolBar(true);
		configurer.setShowStatusLine(false);
		configurer.setTitle("SuperMonitor V1.0");
	}

	/**
	 * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowCreate() 重写，处理窗口打开时最大化
	 * @wbp.parser.entryPoint
	 */
	@Override
	public void postWindowCreate()
	{
		super.postWindowCreate();
		// 打开时，设置最大化模式
		//getWindowConfigurer().getWindow().getShell().setMaximized(true);
	}

}
